<?php
namespace common\service;
use common\models\Error;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/26
 * Time: 17:24
 */
class ErrorService extends BaseService{


    //错误监控入库
    public static function Error(){
        $error_time=time();
        //获取控制器+方法名信息的url
        $error_address=\Yii::$app->request->url;
        //获取host的url
        $error_address_host= \Yii::$app->request->getHostInfo();
        //type为1后台报错，2商家后台报错,3前台报错
        if ($error_address_host=="http://groupbk.com"){
            $error_type=1;
        }else if ($error_address_host=="http://groupba.com"){
            $error_type=2;
        }else if ($error_address_host=="http://groupsh.com"){
            $error_type=3;
        }
        $model=new Error();
        $model->setAttributes(['error_time'=>$error_time,'error_address'=>$error_address,'error_type'=>$error_type]);
        $model->save();

    }

}